﻿@{
    ViewBag.Title = "查询信息";
}
@model FMS.UI.Areas.Factory.ViewModel.Factory_Machines_Search
@section headsecion{
    <style type="text/css">
        body {
            margin: 0;
            align-self: center;
        }

        .tbList {
            border: 1px solid #ddd;
            height: 99.5%;
            border-collapse: collapse;
            margin: 0;
            padding: 0;
            width: 100%;
            border-top-width: 0;
            border-bottom-width: 0;
            border-left-width: 0;
            border-right-width: 0;
        }

        .tbList td, th {
            border: 1px solid #ddd;
            padding: 0 5px;
        }

        .tdName {
            text-align: center;
            width: 85px;
            height: 35px;
        }

        .tdweight {
            width: 220px;
        }

        #form0 {
            margin: 0;
            padding: 0;
        }

        .ui-autocomplete {
            max-height: 110px; /*高度值*/
            overflow-y: auto; /*超过高度出现滚动条*/
            overflow-x: hidden; /*横向超出隐藏，如果要出现横向滚动，设置为auto即可*/
        }
    </style>

    <script type="text/javascript">
        
        $(function() {

            // 去掉所有input的autocomplete, 显示指定的除外
            $('input:not([autocomplete]),textarea:not([autocomplete]),select:not([autocomplete])').attr('autocomplete', 'off');

            var useSeach = '@ViewBag.usrSearch';
            var useSearchBool = useSeach.toLowerCase();
            
            $("#enterTable").click(function () {
               
                var $tbdata = window.top.$("#tabBox") //获取父页面的 选项卡容器
                    .tabs("getSelected") //获取 当前选中的选项卡
                    .children("iframe")[0] //获取 选项卡里的 iframe
                    .contentWindow //获取iframe里的window对象
                    .$("#tbList"); //获取iframe里面页面的 表格组件


                window.setTimeout(function () {
                    $.extend($tbdata.datagrid("options"), {
                        url: '/Factory/FactoryMachines/FactoryMachinesSearch',//这里定义url    
                        queryParams: {
                        "ddInDateCondition": $("#ddInDate").datebox('getValue'),
                        "ddOutDateCondition": $("#ddOutDate").datebox('getValue'),
                        "kind0Condition": $("#kind0").val(),
                        "kind1Condition": $("#kind1").val(),
                        "kind2Condition": $("#kind2").val(),
                        "kind3Condition": $("#kind3").val(),
                        "codeCondition": $("#factory_bar_code").val(),
                        "NameCondition": $("#factory_Machines_Name").val(),
                        "companyCondition": $("#company").val(),
                        "depCondition": $("#dep").val(),
                        "UseStateCondition": $("#factory_Machines_UseState_Id").val(),
                        "EquipmentStatusCondition": $("#factory_Machines_EquipmentStatus_Id").val(),
                        "TypeCondition": $("#factory_Machines_Type_Id").val(),
                        "gongyingCondition": $("#gongying").val()
                    }
                    });
                    $tbdata.datagrid("load");
                }, 100);//延迟100毫秒执行
                           
                $.globalHelper.closeCommonWindow();
            });

            $('#kind0').change(kindOnechange);
            $('#kind1').change(kindTwochange);
            $('#kind2').change(kind3change);
            $('#company').change(selectDep);

            if (useSearchBool == "true") {
                $("#dep").attr("disabled", true);
                $("#company").attr("disabled", true);
            }

        });

        function kindOnechange() {
            var sel = $("#kind1");
            var $kind2 = $("#kind2");
            var $kind3 = $("#kind3");

            sel.empty();
            $kind2.empty();
            $kind3.empty();

            if ($('#kind0  option:selected').text() == '选择') {
                sel.attr("disabled", true);
                $kind2.attr("disabled", true);
                $kind3.attr("disabled", true);
                return;
            }
            var id = this.value;
            $.post("/Factory/Factory_Machines_Kind/Kind1sel", { "id": id }, function(data) {
                sel.append("<option value='0'>选择</optin>");
                $.each(data, function(name, value) {
                    sel.append("<option value=" + value.id + ">" + value.k1name + "</optin>");
                });
            });
        };

        function kindTwochange() {
            var sel = $("#kind2");
            var $kind3 = $("#kind3");
            sel.empty();
            $kind3.empty();
            if ($('#kind1  option:selected').text() == '选择') {
                sel.attr("disabled", true);
                $kind3.attr("disabled", true);
                return;
            }
            var id = this.value;
            $.post("/Factory/Factory_Machines_Kind/Kind2sel", { "id": id }, function(data) {
                sel.append("<option value='0'>选择</optin>");
                $.each(data, function(name, value) {
                    sel.append("<option value=" + value.id + ">" + value.k2name + "</optin>");
                });
            });
        };

        function kind3change() {
            var sel = $("#kind3");
            sel.empty();
            if ($('#kind2  option:selected').text() == '选择') {
                sel.attr("disabled", true);
                return;
            }
            sel.attr("disabled", false);
            var id = this.value;
            $.post("/Factory/Factory_Machines_Kind/Kind3sel", { "id": id }, function(data) {
                sel.append("<option value='0'>选择</optin>");
                $.each(data, function(name, value) {
                    sel.append("<option value=" + value.id + ">" + value.k2name + "</optin>");
                });
            });
        };

        function selectDep() {
            var sel = $("#dep");
            sel.empty();
            if ($('#company  option:selected').text() == '选择') {
                sel.attr("disabled", true);
                return;
            }
            sel.attr("disabled", false);
            var id = this.value;


            $.post("/Admin/Department/SelectDep", { "id": id }, function(data) {
                sel.append("<option value='0'>选择</optin>");
                $.each(data, function(name, value) {
                    sel.append("<option value=" + value.depId + ">" + value.depName + "</optin>");
                });
            });


        };
    </script>
}
    <table id="tbList" class="tbList">
        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_UseDateIn)</td>
            <td><input id="ddInDate" type="text" class="easyui-datetimebox" required="required" name="factory_Machines_UseDateIn"></td>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_UseDateOute)</td>
            <td><input id="ddOutDate" type="text" class="easyui-datetimebox" required="required" name="factory_Machines_UseDateOute"></td>
        </tr>
        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_Kind_Type_Id)</td>
            <td class="tdweight">@Html.DropDownListFor(o => o.factory_Machines_Kind_Type_Id, ViewBag.Machines_Kind_Type as IEnumerable<SelectListItem>, "选择分类", new { style = "width:135px ", select = "size:10", id = "kind0" })</td>
            <td class="tdName">二级分类</td>
            <td class="tdweight"> <select id=kind1 style="width: 135px" name="factory_Machines_Kind1_Id"></select></td>
        </tr>
        <tr>
            <td class="tdName">三级分类</td>
            <td> <select id=kind2 style="width: 135px" name="factory_Machines_Kind2_Id"></select></td>
            <td class="tdName">设备类型</td>
            <td> <select id=kind3 style="width: 135px" name="factory_Machines_Kind_Id"></select></td>
        </tr>
        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_bar_code)</td>
            <td>@Html.TextBoxFor(o => o.factory_bar_code)</td>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_Name)</td>
            <td>@Html.TextBoxFor(o => o.factory_Machines_Name)</td>

        </tr>
        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.Factory_Machines_Company_Id)</td>
            <td>@Html.DropDownListFor(o => o.Factory_Machines_Company_Id, ViewBag.Machines_Company as IEnumerable<SelectListItem>, "选择公司", new { style = "width:135px ", id = "company" })</td>
            <td class="tdName">部门名称</td>
            <td><select id="dep" name="factory_Machines_Department_Id" style="width: 135px"></select></td>
        </tr>
        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_supplier_Id)</td>
                <td>
                    @Html.TextBoxFor(o => o.factory_Supplier_Id_Name, new {id = "gongying"})                 
                </td>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_UseState_Id)</td>
            <td>@Html.DropDownListFor(o => o.factory_Machines_UseState_Id, ViewBag.Machines_UseState as IEnumerable<SelectListItem>, "", new { style = "width:135px ", select = "size:10" })</td>
        </tr>
        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_EquipmentStatus_Id)</td>
            <td>@Html.DropDownListFor(o => o.factory_Machines_EquipmentStatus_Id, ViewBag.Machines_EquipmentStatus as IEnumerable<SelectListItem>, "", new { style = "width:135px ", select = "size:10" })</td>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_Type_Id)</td>
            <td>
                @Html.DropDownListFor(o => o.factory_Machines_Type_Id, ViewBag.Machines_Type as IEnumerable<SelectListItem>, "", new { style = "width:135px ", select = "size:10" })
            </td>
        </tr>
        <tr>
            <td colspan="4" style="text-align: center; border: 0 solid white; padding-top: 7px">
                <input id="enterTable" type="submit" value="快速查询" style="height: 27px; width: 68px; cursor: pointer" />
            </td>
        </tr>
    </table>

